/*
 * @Author: 
 * @Date: 2022-01-26 17:25:57
 * @LastEditors: lqj
 * @LastEditTime: 2022-01-27 09:36:12
 * @Description: 请填写简介
 */
// const proxy = require('http-proxy-middleware')
const { createProxyMiddleware: proxy } = require('http-proxy-middleware')

module.exports = function(app) {
  app.use(
    proxy('/api1', { // 触发前缀配置
      target: 'http://localhost:5000', // 请求转发
      changeOrigin: true, // 控制发控制器收到的请求头中Host字段的值
      pathRewrite: { '^/api1': '' } // 重写请求路径
    }),
    proxy('/api2', {
      target: 'http://localhost:5001',
      changeOrigin: true,
      pathRewrite: { '^/api2': '' }
    }),
  )
}